home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Online / CNetDemo / cnet / sdk / Examples / NetEchoList.lha / NetEchoList.c next >
Encoding:
C/C++ Source or Header  |  1996-06-18  |  2.9 KB  |  133 lines

  1. /**************************************************************************
  2.  * NetEchoList.c - List all configured Fidonet areas in CNet
  3.  **************************************************************************/
  4.  
  5. #include "NetEchoList.h"
  6.  
  7. BOOL CheckConfigured( char *ZeroPath );
  8. void GetOut ( void );
  9.  
  10.  
  11. short                        FidoType=-1;
  12. char                        EchoFile[] = "cnet:bbsechos";
  13. char                        GenBuff[256];
  14. struct    EchoList        Echo1;
  15. struct    MainPort        *myp=NULL;
  16. BOOL                        ControlRunning=FALSE;
  17.  
  18. LONG        Listed=0;
  19.  
  20. UBYTE *vers="$VER:v1.0 NetEchoList (03-11-95)";
  21.  
  22. void main(int argc, char *argv[])
  23. {
  24.     FILE *fp;
  25.     short xxx=0;
  26.  
  27.     atexit(GetOut);
  28.  
  29.     if( myp = (struct MainPort *)FindPort("cnetport") )
  30.         {
  31.         ControlRunning=TRUE;
  32.  
  33.         printf("\nAvailable networks:\n\n");
  34.         for(xxx=0;((xxx<myp->gc.nfido) && strlen(myp->gc.fido[xxx].Name));xxx++)
  35.             {
  36.             printf("    %d. %s\n", xxx+1, myp->gc.fido[xxx].Name);
  37.             }
  38.         if(xxx > 0)
  39.             {
  40.             printf("\nChoose a network [RETURN/ENTER = ALL]: ");
  41.             fflush(stdout);
  42.             FidoType=-1;
  43.             if(gets(GenBuff))
  44.                 {
  45.                 FidoType = atoi(GenBuff)-1;
  46.                 printf("%c", 12);    /* clear screen */
  47.                 }
  48.             }
  49.         }
  50.     else
  51.         {
  52.         printf("\nNote: Base0/Net-type listing disabled while CNet/Control not loaded\n");
  53.         }
  54.  
  55.     if(fp=fopen(EchoFile, "r"))
  56.         {
  57.         if(FidoType == -1)
  58.             {
  59.             printf("\nConfigured echos           Fido Type                                  In Base0?\n");
  60.             }
  61.         else
  62.             {
  63.             printf("\nConfigured echos                                                      In Base0?\n");
  64.             }
  65.         
  66.         while(fread((char *)&Echo1.EchoType, sizeof(struct EchoType), 1, fp))
  67.             {
  68.             Echo1.Configured=FALSE;
  69.  
  70.             if(ControlRunning)
  71.                 {
  72.                 Echo1.Configured = CheckConfigured(Echo1.EchoType.Title);
  73.  
  74.                 if(FidoType == -1)
  75.                     {
  76.                     Listed++;
  77.                     printf("%-24.24s [%10.10s ] %-33.33s %s\n", Echo1.EchoType.Title, myp->gc.fido[ Echo1.EchoType.domain ].Name, Echo1.EchoType.Info, (Echo1.Configured) ? "Yes":"No");
  78.                     }
  79.                 else
  80.                     {
  81.                     /* Does current echo belong the requested net? */
  82.                     if(Echo1.EchoType.domain == FidoType)
  83.                         {
  84.                         Listed++;
  85.                         printf("%-24.24s %-48.48s %s\n", Echo1.EchoType.Title, Echo1.EchoType.Info, (Echo1.Configured) ? "Yes":"No");
  86.                         }
  87.                     }
  88.                 }
  89.             else
  90.                 {
  91.                 Listed++;
  92.                 printf("%-24.24s %-48.48s %s\n", Echo1.EchoType.Title, Echo1.EchoType.Info, "Unknown");
  93.                 }
  94.             }
  95.         fclose(fp);
  96.         }
  97.  
  98.     if(!Listed)
  99.         {
  100.         printf("[No match/empty]\n");
  101.         }
  102.     else
  103.         {
  104.         printf("Listed %ld echos\n", Listed);
  105.         }
  106.     exit(0);
  107. }
  108.  
  109.  
  110. BOOL CheckConfigured( char *SubDirName )
  111. {
  112.     struct NewSubboardType *sub1;
  113.     LONG zzz=0;
  114.  
  115.     for(zzz=0;zzz<myp->ns;zzz++)
  116.         {
  117.  
  118. //printf("comparing subboard %s with %s\n", myp->Subboard[zzz].SubDirName, SubDirName);
  119.  
  120.         if(!stricmp(myp->Subboard[zzz].SubDirName, SubDirName))
  121.             {
  122.             return TRUE;
  123.             }
  124.         }
  125.     return FALSE;
  126. }
  127.  
  128.  
  129. void GetOut ( void )
  130. {
  131.     printf("NetEchoList %5.5s copyright © 1995-1996 MetalSoft.\n", vers+5);
  132. }
  133.